﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SendCloudMail
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void click_evt(object sender, EventArgs e)
        {
            SendOnebyOne();
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox3.Text = "";
        }

        void SendAll()
        {
            string revicer = TextBox1.Text;
            string subject = TextBox2.Text;
            string content = HttpUtility.HtmlEncode(TextBox3.Text);
            string emlist = TextBox4.Text.Trim();
            //Response.Write(content);
            content = HttpUtility.HtmlDecode(content);
            //Response.Write(content);
            Example.WebAPISendMail(emlist, subject, content, emlist);
        }
        
        void SendOnebyOne()
        {
            string revicer = TextBox1.Text;
            string subject = TextBox2.Text;
            string content = HttpUtility.HtmlEncode(TextBox3.Text);
            //Response.Write(content);
            content = HttpUtility.HtmlDecode(content);
            //Response.Write(content);


            string[] emails = revicer.Split(';');
            for (int i = 0; i < emails.Length;i ++ )
            {
                if (!string.IsNullOrEmpty(emails[i]))
                {

                    Example.WebAPISendMail(emails[i], subject, content,"");
                    Response.Write(emails[i] + " Sended Is OK! <br>");
                }
                
            }
        }
    }
}